package com.compass.mobile.ui.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.mobile.R
import com.compass.mobile.callback.OnCustomButtonClick
import com.compass.mobile.databinding.LayoutItemAddPatientListBinding
import com.compass.mobile.databinding.LayoutItemCommonBinding
import com.compass.mobile.framework.adapter.BaseBindViewHolder
import com.compass.mobile.framework.adapter.BaseRecyclerViewAdapter
import com.compass.mobile.framework.ext.onClick
import com.compass.mobile.models.CommonBean
import com.compass.mobile.models.PatientBean
import dp2px
import setUrl
import setUrlCircle
import setUrlRound

/**
 * Description：
 * Date:2024/7/4 14:25
 */
class PatientAddListAdapter : BaseRecyclerViewAdapter<PatientBean, LayoutItemAddPatientListBinding>() {


    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutItemAddPatientListBinding {
        return LayoutItemAddPatientListBinding.inflate(layoutInflater, parent, false)
    }

    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutItemAddPatientListBinding>,
        item: PatientBean?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
//            tvName.text= "${item.name}  ${item.sex}  年龄:${item.age}"
//            ivDoctorAvatar.setUrlCircle()
            if(item.avatar.isNullOrEmpty()){
                ivDoctorAvatar.setImageResource(R.mipmap.default_head)
            }else{
                ivDoctorAvatar.setUrlRound(item.avatar, dp2px(5f))
            }

            ivDoctorAvatar.setUrlRound(item.avatar, dp2px(5f))
            tvName.text = item.name
            tvAge.text = "年龄：${item.age}"
            tvSex.text = if(item.sex == "1") "性别：男" else if( item.sex == "2") "性别：女" else "性别：未知"
        }
    }
}